package com.dongdongshop.serviceimpl;

import com.dongdongshop.mapper.TbUserScoreAccountMapper;
import com.dongdongshop.pojo.TbUserScoreAccount;
import com.dongdongshop.pojo.TbUserScoreAccountExample;
import com.dongdongshop.service.TbUserScoreAccountservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class TbUserScoreAccountserviceImpl implements TbUserScoreAccountservice {
    @Autowired
    private TbUserScoreAccountMapper tbUserScoreAccountMapper;
    @Override
    public void insertTsa(TbUserScoreAccount tsa) {
        tbUserScoreAccountMapper.insertSelective(tsa);
    }

    //按照用户名 查找积分表
    @Override
    public TbUserScoreAccount selectByUserId(String userId) {
        TbUserScoreAccountExample te = new TbUserScoreAccountExample();
        TbUserScoreAccountExample.Criteria criteria = te.createCriteria();
        criteria.andUseridEqualTo(userId);
        List<TbUserScoreAccount> tbUserScoreAccounts = tbUserScoreAccountMapper.selectByExample(te);
        if (tbUserScoreAccounts.size() < 1){
            return null;
        }
        return tbUserScoreAccounts.get(0);
    }

    //追加积分
    @Override
    public void updateAcc(TbUserScoreAccount acc) {
        tbUserScoreAccountMapper.updateByPrimaryKeySelective(acc);
    }
}
